//
//  GroupOrderDetailCtr.swift
//  eemall
//
//  Created by zhuxietong on 2019/1/8.
//  Copyright © 2019 tianrun. All rights reserved.
//

import Foundation
import soapp
import Eelay
import AsyncDisplayKit

open class GroupOrderDetailCtr: ShoppingOrderDetailCtr {
    var teamid:String{
        get{
            return mo.model["teamid",""]
        }
    }
    open override func viewDidLoad() {
        self.scheme = .group
        super.viewDidLoad()
    }
    override open func mo_request_send() {
        GMsgType.groups.msg.readOne(ID: teamid)
        GMsgType.groups_order.msg.readOne(ID: teamid)

        weak var wself = self
        loadingV.loading()
        JoTask().get.log.params(["orderid":orderID,"teamid":teamid]).log_response()._surl(.团购订单详情).json_handle { (status, msg, obj, resp) in
            wself?.loadingV.dismiss()
            if status.isSuccess{
                if let dict = obj as? NSMutableDictionary{
                    wself?.mo.detail = dict
                    return
                }
            }
            wself?.mo_request_alert(msg: msg, title: "", bt_title: "重试".loc)
        }.run()
    }
    
    override open func mo_model_reload() {
        
        self.__link = "groupsorder?teamid=\(teamid)&orderid=\(orderID)"
//        self.__link = EeURLCreator(path: GroupLink.groupOrder.rawValue, params: ["teamid":teamid,"orderid":orderID]).rawUrl
//        print("++++++PPP|\(self.__link)")
        
    }
    
    override open func mo_detail_reload() {
        tableNode.load(sections: sections, selector: selector)
        tableNode.reloadData()
        //        let msgid = MsgMap.getMsgID(type: .order, objID: self.orderID)
        GMsgType.groups.msg.readOne(ID: teamid)
        GMsgType.groups_order.msg.readOne(ID: orderID)
        
        GMsgType.groups.msg.readOne(ID: orderID)
        GMsgType.groups_order.msg.readOne(ID: teamid)

    }
}
